interface ISeries {
  data: number[]
  name: string
  type: string
  [key: string]: any
}
export const getOptions = (xData: string[], series: ISeries[]) => {
  const legendData: string[] = []
  const seriesData: any[] = []
  series.forEach(item => {
    legendData.push(item.name)
    seriesData.push(
      Object.assign(
        { barMaxWidth: 20 }, item
      )
    )
  })

  const option = {
    legend: {
      data: legendData,
      bottom: 0,
      textStyle: {
        color: '#fff'
      },
      padding: [15, 10],
      itemGap: 20
    },
    color: [
      '#29F1FA',
      '#5470c6',
      '#91cc75',
      '#fac858',
      '#ee6666',
      '#73c0de',
      '#3ba272',
      '#fc8452',
      '#9a60b4',
      '#ea7ccc'
    ],
    grid: {
      top: '40px',
      left: '40rem',
      right: '40rem',
      bottom: '60px'
    },
    tooltip: {
      trigger: 'axis'
    },
    xAxis: {
      type: 'category',
      axisLabel: {
        color: '#777'
      },
      splitLine: {
        lineStyle: {
          color: ['#777']
        }
      },
      data: xData //['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
    },
    yAxis: [
      {
        type: 'value',
        name: '收益',
        axisLabel: {
          formatter: '{value} ml'
        }
      },
      {
        type: 'value',
        name: '发电量',
        axisLabel: {
          formatter: '{value} °C'
        }
      }
    ],
    // {
    //   type: 'value',
    //   axisLabel: {
    //     color: '#777'
    //   },
    //   splitLine: {
    //     lineStyle: {
    //       color: ['#777']
    //     }
    //   },
    //   name: '单位：MW'
    // },
    series: seriesData
    // [
    //   {
    //     data: [820, 932, 901, 934, 1290, 1330, 1320],
    //     name: 'a',
    //     type: 'bar',
    //     // barWidth: 1,
    //     barMaxWidth: 10,
    //   },
    //   {
    //     data: [820, 932, 901, 934, 1290, 1330, 1320],
    //     name: 'b',
    //     type: 'bar',
    //     // barWidth: 1,
    //     barMaxWidth: 10,
    //   }
    // ]
  }
  return option
}